import MDP
import config
from mdwrkapi import MajorWorker

def main():
    broker_server = "%s://%s:%d" % (config.PROTOCOL, config.BROKER_IP, config.PORT)
    worker = MajorWorker(broker_server, config.WORKER_NAME_PREFIX + str(1))

    while True:
        request = worker.recv()
        print "server recv: ", request

        if request is None:
            continue

        # handle logic
        # assert worker.reply_to is not None
        # reply = [worker.reply_to, ''] + request
        # print reply
        # worker.send_to_broker(MDP.W_REPLY, msg=reply)

if __name__ == '__main__':
    main()
